package com.shangbang.verb.controller.recruit;

import com.shangbang.verb.core.BaseResponse;
import com.shangbang.verb.service.recruit.NounService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Api(value = "用户操作简历类接口", tags = "用户简历相关接口", description = "用户简历的新增、更新")

@RestController
@RequestMapping(value = "/recruit/noun")
public class NounController {

    @Autowired
    private NounService nounService;

    /**
     * 创建用户简历
     * @param request
     * @param response
     * @param userDefault
     * @param workDefault
     * @param uid
     * @return
     */
    @ApiOperation(value = "用户创建简历接口",notes = "")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userDefault", value = "用户信息", required = false, dataType = "String"),
            @ApiImplicitParam(name = "workDefault", value = "工作信息", required = false, dataType = "String"),
            @ApiImplicitParam(name = "uid", value = "用户id", required = true, dataType = "Integer")
    })
    @RequestMapping(value = "/createNoun", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse createNoun(HttpServletRequest request, HttpServletResponse response,
                                 @RequestParam(required = false) String userDefault,
                                 @RequestParam(required = false) String workDefault,
                                 @RequestParam(required = true) Integer uid) {
        Object result = "";
        Integer code = 0;
        String msg = "成功";

        result =  nounService.createNoun(userDefault,workDefault,uid);


        return new BaseResponse(code, msg, result);
    }

    /**
     * 修改用户简历
     * @param request
     * @param response
     * @param userDefault
     * @param workDefault
     * @return
     */
    @ApiOperation(value = "用户修改简历接口",notes = "用户根据简历的id进行修改，请注意")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userDefault", value = "用户信息", required = false, dataType = "String"),
            @ApiImplicitParam(name = "workDefault", value = "工作信息", required = false, dataType = "String"),
            @ApiImplicitParam(name = "nonid", value = "简历的id", required = true, dataType = "int")
    })
    @RequestMapping(value = "/updateNoun", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse updateNoun(HttpServletRequest request, HttpServletResponse response,
                                   @RequestParam(required = false) String userDefault,
                                   @RequestParam(required = false) String workDefault,
                                   @RequestParam(required = true) Integer nonid) {
        Object result = "";
        Integer code = 0;
        String msg = "成功";

        result =  nounService.updateNoun(userDefault,workDefault,nonid);


        return new BaseResponse(code, msg, result);
    }
    /**
     * 获取用户简历
     * @param request
     * @param response
     * @param uid
     * @return
     */
    @ApiOperation(value = "用户获取简历接口",notes = "每一个用户只能有一份简历")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户的id", required = true, dataType = "int")
    })
    @RequestMapping(value = "/getNoun", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse getNoun(HttpServletRequest request, HttpServletResponse response,
                                   @RequestParam(required = true) Integer uid) {
        Object result = "";
        Integer code = 0;
        String msg = "成功";

        result =  nounService.getNoun(uid);


        return new BaseResponse(code, msg, result);
    }



}
